// pages/User/homepage/homepage.js
var app = getApp();
var Api = require("../../../api/method.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    class: "",
    shouquan:true,
    system:""
  },
  //查看更多
  more: function (e) {
    if (!wx.getStorageSync("user")) {
      this.setData({
        shouquan: false
      })
      return
    }
    console.log(e.currentTarget.dataset.id);
    wx.navigateTo({
      url: "/pages/Salesman/Easier/easier?id=" + e.currentTarget.dataset.id + "&name=" + e.currentTarget.dataset.name,
    });
  },
  //隐藏白条弹框
  hideBaitiaoView: function (e) {
    if (e.target.dataset.target == 'self')
      this.setData({
        shouquan: true
      })
  },
  //专栏列表
  columnResult: function (e) {
    let that = this;
    let list = {
    };
    Api.columnResult(list, function (err, res) {
      console.log(res.data);
      if (res.data.code == 1) {
        that.setData({
          class: res.data.data
        })
      }
    });
  },
  //退出登录
  goout: function () {
    wx.clearStorage();
    wx.navigateTo({
      url: '/pages/Portalpage/Portalpage',
   })
  },
  //账号密码登录
  login: function (e) {
    wx.redirectTo({
      url: "/pages/login/login",
    })
  },
  //点击跳转
  valueTxt: function (e) {
    if(!wx.getStorageSync("user")){
      this.setData({
        shouquan:false
      })
      return
    };
    wx.navigateTo({
      url: "/pages/User/Catalog/Catalog?columnid=" + e.currentTarget.dataset.columnid,
    })
  },
  //授权
  likesClick:function(e){
    this.setData({
      shouquan: true
    });
    this.columnResult();
  },
  //获取设备型号
  getSystemInfo:function(e){
      var that = this;
      wx.getSystemInfo({
        success: function (res) {
          // console.log(res)
          var system = res.system.replace(/[^a-z]+/ig, "");
          that.setData({
            system: system
          })
        }
      });
    },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.columnResult();
    this.getSystemInfo();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    app.editTabBar2();    //显示自定义的底部导航
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})